package view_server

import (
	"bigdevops/src/common"
	"bigdevops/src/models"
	"fmt"
	"github.com/gin-gonic/gin"
	"go.uber.org/zap"
)

type CommonSelectResponse struct {
	Label string `json:"label"`
	Value string `json:"value"`
}

type BatchSwitchRequest struct {
	Ids []int `json:"ids"`
}

// 公共的方法 传入 userNames 给你Users
func commonGetUsersByNames(userNames []string, logger *zap.Logger, c *gin.Context) (res []*models.User) {

	// 转化 userNames 到 members
	for _, userName := range userNames {
		userName := userName
		dbUser, err := models.GetUserByUserName(userName)
		if err != nil {
			logger.Error("通过token解析到的userName去数据库中找User失败",
				zap.Error(err),
			)
			common.ReqBadFailWithMessage(fmt.Sprintf("通过token解析到的userName去数据库中找User失败:%v", err.Error()), c)
			return
		}
		res = append(res, dbUser)

	}
	return

}
